package com.jinsilu.freight.ui.adapter;

import android.graphics.Color;
import android.text.TextUtils;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.jinsilu.freight.R;
import com.jinsilu.freight.http.response.RecordWhiteNoteBean;
import com.jinsilu.freight.ui.activity.BlankNoteActivity;

import java.util.List;

/**
 * 白条列表
 *
 * @author byd
 * @time 2022/04/08 17:22
 */
public class BlankNoteAdapter extends BaseQuickAdapter<RecordWhiteNoteBean, BaseViewHolder> {

    public BlankNoteAdapter(@Nullable List<RecordWhiteNoteBean> data) {
        super(R.layout.item_blank_note, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, RecordWhiteNoteBean item) {
        LinearLayout layout = holder.getView(R.id.item_view);
        if (!TextUtils.isEmpty(item.getBusinessType()) && BlankNoteActivity.WHITE_TYPE_OF_TIME_ISSUE_DATE.equals(item.getBusinessType())) {
            layout.setBackgroundColor(Color.parseColor("#FFFFFF"));
        } else {
            layout.setBackgroundColor(Color.parseColor("#EEEEEE"));
        }
        holder.setText(R.id.tv_waybill_number, String.format("运单号：%s", item.getWaybillNumber()))
                .setText(R.id.tv_used_amount, String.format("￥%s", item.getPayMoney()))
                .setText(R.id.tv_blank_note_name, String.format("货主名称：%s", item.getPartnerName()))
                .setText(R.id.tv_line_start_address, String.format("车牌号：%s", item.getVehicleNumber()))
//                .setText(R.id.tv_blank_note_name, String.format("货品名称：%s", s))
                .setText(R.id.tv_time_of_issue, String.format("发放时间：%s", item.getCreateTime()));
    }
}
